<template>
	<view>
		<uni-card>
			<view @click="dianji(index)">
				<view class=" user-box u-p-l-30 u-p-r-20 u-p-b-30 u-border-bottom u-padding-top-10"
					style="display: flex;">
					<view class="u-m-r-10">
						<u-avatar :src="base+item.doctor.avatar" size="100"></u-avatar>
					</view>
					<view class="u-flex-1">
						<view class="u-font-18 u-p-b-20">{{item.doctor.name}}</view>
						<view class="u-font-18 u-p-b-20">职称:{{item.doctor.jobName}}</view>
						<view class="u-font-18 u-p-b-20">执业编号:{{item.doctor.practiceNo}}</view>
						<view class="u-font-18 u-p-b-20">从业年限时间:{{item.doctor.workingYears}}</view>
						<view class="u-font-14 u-tips-color">咨询描述:{{item.question}}</view>

					</view>
				</view>
			</view>
		</uni-card>
		<uni-card title="聊天列表">
			<view  class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30 u-border-bottom">
				<view class="u-m-r-10">
					<u-avatar :src="base+item.doctor.avatar" size="50"></u-avatar>
				</view>
				<view class="u-flex-1">
					<view class="u-font-14 u-tips-color">你好，请问有什么问题吗</view>
				</view>
			</view>
			<view v-for="(item1,index) in liao">
				<view v-if="item1.fromRole == 1" class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30 u-border-bottom">
					<view class="u-m-r-10">
						<u-avatar :src="base+item.doctor.avatar" size="50"></u-avatar>
					</view>
					<view class="u-flex-1">
						<view class="u-font-14 u-tips-color">{{item1.content}}</view>
					</view>
				</view>
				<view v-if="item1.fromRole == 0" class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30 u-border-bottom">
					<view class="u-flex-1 u-text-right">
						<view class="u-font-14 u-tips-color">{{item1.content}}</view>
					</view>
					<view class="u-m-l-10 u-padding-top-10 ">
						<u-avatar src="base+item.doctor.avatar" size="50"></u-avatar>
					</view>
				</view>
			</view>
		</uni-card>
		<view style="height: 20vh;" class="">
			
		</view>
		<uni-group style="position:fixed;z-index: 99;right: 0%;bottom: 0%;left: 0%;">
			<view class="u-flex">
				<uni-easyinput v-model="value"></uni-easyinput>
				<button type="primary" @click="fian">发送</button>
			</view>
		</uni-group>
	</view>
</template>

<script>
	import api from 'commer/apiURL.js'
	export default {
		data() {
			return {
				base: api.baseurl,
				item: '',
				liao: [],
				value: ''
			}
		},
		onLoad() {
			this.getlun()
			this.item = uni.getStorageSync('wen')
		},
		methods: {
			fian() {
				if (this.value == '') {
					uni.showToast({
						title: '请输入内容',
						icon: 'none'
					})
					return
				}
				this.$post(this.base + '/prod-api/api/pet-hospital/inquiry-message', {
					"inquiryId": this.item.id,
					"content": this.value
				}).then((res) => {
					if (res.code == 200) {
						uni.showToast({
							title: '发送成功'
						})
						this.value = ''
						this.getlun(this.item.id)
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			},
			getlun() {
				let item = uni.getStorageSync('wen')
				console.log(item)
				this.$get(this.base + '/prod-api/api/pet-hospital/inquiry-message/list', {
					inquiryId: item.id
				}).then((res) => {
					this.liao = res.rows
				})
			},


		}
	}
</script>

<style>

</style>
